﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RentalCalcV4
{
    /// <summary>
    /// The rental class, 
    /// One Rental instance hold one Movie instance
    /// </summary>
    public class Rental
    {

        public Rental()
        {
        }

        /// <summary>
        /// Create a new instance of the Rental class
        /// </summary>
        /// <param name="movie"></param>
        /// <param name="daysRented"></param>
        public Rental(Movie movie, int daysRented)
        {
            RentedMovie = movie;
            DaysRented = daysRented;
        }

        /// <summary>
        /// Gets or sets the movie instance of the Rental object
        /// </summary>
        public Movie RentedMovie
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the date range the movie will be rented
        /// </summary>
        public int DaysRented
        {
            get;
            set;
        }

        /// <summary>
        /// Calculate the price of one rental
        /// </summary>
        /// <returns>the price</returns>
        public double GetCharge()
        {
            double result = 0;

            switch (RentedMovie.PriceCode)
            {
                case Movie.CHILDREN:
                    result += 1;
                    if (DaysRented > 2)
                    {
                        result += (DaysRented - 2) * 1;
                    }
                    break;
                case Movie.EMOTION:
                    result += 1.5;
                    if (DaysRented > 3)
                    {
                        result += (DaysRented - 3) * 1.5;
                    }
                    break;
                case Movie.WAR:
                    result += DaysRented * 2;
                    break;
                default:
                    break;
            }
            return result;
        }

        /// <summary>
        /// Calculate the memeber points of one rental
        /// </summary>
        /// <returns>memeber points</returns>
        public int GetPoints()
        {
            if (RentedMovie.PriceCode == Movie.WAR && DaysRented > 2)
            {
                return 2;
            }
            else
            {
                return 1;
            }
        }
    }
}
